{
	template:`
	<a-page-header title="会员订单"  >
		<template #extra>
		    <a-alert v-if="!model.oid" style="display: inline-block;margin: -5px 0;" message="保存后添加订单明细"></a-alert>
			<a-popconfirm v-else title="确定要提交吗？" @confirm="save(submit)">
			    <a-button type="primary success">提交</a-button>
			</a-popconfirm>
			<a-button type="primary" @click="save(null)">保存</a-button>
			<m-back @click="back(false);">关闭</m-back>
		</template>
		<a-card :hoverable="true" :bodyStyle="{padding:'20px 20px 0'}">
			<a-form class="index-form" :wrapper-col="{span:24}">
				<a-row :gutter="10">
					<a-col :span="16">
						<a-form-item label="会员信息" class="index-form-item">
						    <template v-if="model.member.oid">
						        <a-tag :color="model.member.level.color">{{model.member.level.name}}</a-tag>
						        <a-tag color="success" v-if="model.member.level.discount">优惠{{model.member.level.discount}}%</a-tag>
						        {{model.member.realName}} {{model.member.phoneNum}}
						        <small>余额</small><span class="text-red">{{formatNumber(model.member.balance-model.member.freeze,'#,##0.00')}}</span><small>元</small>
						    </template>
							<a-button class="margin-left-sm" type="primary" size="small" @click="selectOneModel(model,'member','action/member/manage/memberInfo/selectList',750)">选择</a-button>
						</a-form-item>
					</a-col>
					<a-col :span="8">
						<a-form-item label="服务员" class="index-form-item">
							{{model.serveAdmin.realname}}
							<a-button v-if="confirmPower" class="margin-left-sm" type="primary" size="small" @click="selectOneAdmin(model,'serveAdmin',model.inputDept.oid,'')">选择</a-button>
						</a-form-item>
					</a-col>
					<a-col :span="16">
						<a-form-item label="付款类型" class="index-form-item">
							<a-radio-group v-model:value="model.payType" :options="dictOptions('m.member.order.model.OrderInfo!payType')" />
						</a-form-item>
					</a-col>
					<a-col :span="8" v-if="model.payType=='0'">
                        <a-alert v-if="parseFloat(formatNumber(model.payAmount-(model.member.balance-model.member.freeze),'0.00'))>0" type="error" class="text-center" style="margin:-5px 0;">
                            <template #message>
                                <span style="padding-right:40px;">差{{formatNumber(model.payAmount-(model.member.balance-model.member.freeze),'#,##0.00')}}元</span>
                                <a-checkbox-group v-model:value="model.payOper" :options="dictOptions('m.member.order.model.OrderInfo!payOper')" />
                            </template>
                        </a-alert>
					</a-col>
				</a-row>
				<a-row :gutter="10">
					<a-col :span="8">
						<a-form-item label="其他金额" class="index-form-item">
							<a-input-number v-model:value="model.otherAmount" :precision="2" addon-after="元" />
						</a-form-item>
					</a-col>
					<a-col :span="16">
					    <a-alert style="margin: -5px 0;" message="若该订单有其他优惠(填负数)或补差价(填正数)，请再其他金额处填写，填写后请及时保存。"></a-alert>
					</a-col>
					<a-col :span="24">
						<a-form-item label="备注" class="index-form-item">
							<a-input v-model:value="model.remark" />
						</a-form-item>
					</a-col>
					<a-col :span="8">
						<a-form-item label="录入人" class="index-form-item">
							{{model.inputAdmin.realname}}
						</a-form-item>
					</a-col>
					<a-col :span="8">
						<a-form-item label="录入店铺" class="index-form-item">
							{{model.inputDept.name}}
						</a-form-item>
					</a-col>
					<a-col :span="8">
						<a-form-item label="录入时间" class="index-form-item">
							{{formatDate(model.inputDate,'yyyy-MM-dd')}}
						</a-form-item>
					</a-col>
					<template v-if="model.oid">
                        <a-col :span="6">
                            <a-form-item label="订单金额" class="index-form-item">
                                <span class="text-red text-lg">{{model.orderAmount}}</span>元
                            </a-form-item>
                        </a-col>
                        <a-col :span="12">
                            <a-form-item class="index-form-item-no">
                                会员优惠 <span class="text-red text-lg">{{model.preferentialAmount}}</span>元
                                <span v-if="model.otherAmount" class="padding-left">
                                    其他金额 <span class="text-red text-lg">{{model.otherAmount}}</span>元
                                    <span v-if="otherAmount!=model.otherAmount" class="text-red text-sm">(未保存)</span>
                                </span>
                                <span v-if="model.memberDayAmount" class="padding-left">
                                    会员日 <span class="text-red text-lg">{{model.memberDayAmount}}</span>元
                                </span>
                            </a-form-item>
                        </a-col>
                        <a-col :span="6">
                            <a-form-item label="实付金额" class="index-form-item">
                                <span class="text-red text-lg">{{model.payAmount}}</span>元
                            </a-form-item>
                        </a-col>
					</template>
				</a-row>
			</a-form>
		</a-card>
	</a-page-header>
	<div id="orderDetail_list" style="margin-top:-15px;"></div>
	`,
	props: ['localeZh','param','parentVue'],
	data:function(){
		return {
			model:{"member":{},"serveAdmin":{},"inputAdmin":{},"inputDept":{},otherAmount:0},
			confirmPower:false,
			otherAmount:0
		};
	},
	mounted(){
        this.model.oid=this.param.oid;
        this.loadModel(this.loadDetail);
	},
	methods:{
	    notifyHandler:function(flag,type,obj,url){
	        if(this.model.oid&&flag
	            &&url.indexOf('action/member/order/orderDetail/subList')>=0){
	            this.loadModel();
	        }
	    },
	    loadModel:function(fn){
			this.requestData('action/member/order/orderInfo/getInfo',
				{model:this.model},
				data=>{
					if(!data.code){
						this.model=data.model;
						this.confirmPower=data.confirmPower;
						this.otherAmount=this.model.otherAmount;
						if(fn) fn();
					}else{
						this.$message.error(data.msg);
					}
				}
			);
	    },
	    loadDetail:function(){
            this.loadPage("orderDetail_list",
                "action/member/order/orderDetail/subList",
                {params:{'oper':this.model.status=='A'?'edit':'','order.oid':this.model.oid}},
                function(pv,v3){

                }.bind(this)
            );
	    },
		save:function(fun){
			this.requestData('action/member/order/orderInfo/doSave',
				{model:this.model},
				data=>{
					if(!data.code){
						this.model=data.model;
						this.otherAmount=this.model.otherAmount;
						if(fun) {
						    fun();
						} else {
						    this.$message.success(data.msg);
                            this.loadDetail();
                        }
					}else{
						this.$message.error(data.msg);
					}
				}
			);
		},
		submit:function(){
			this.requestData('action/member/order/orderInfo/doSubmit',
				{model:this.model},
				data=>{
					if(!data.code){
						this.$message.success(data.msg);
						this.back(true);
					}else{
						this.$message.error(data.msg);
					}
				}
			);
		}
	}
}